<?php

namespace Managers;

class Calculate extends BaseManager
{
       protected $__table = '\Catalog\Users';




    public  function  getList()

    {

         return $this->_em->createQueryBuilder()
                ->select("u,calc")
                ->from($this->__table, "u")
                 ->join('u.calculations','calc')
                ->getQuery()
                ->getArrayResult();
    }


public function addUser($ip,$calcid)
    {

     
        $user = new \Catalog\Users();
        $user->setiP($ip);
        $calcRef = $this->_em->getReference('\Catalog\Calculations', $calcid);
        $user->setCalculations($calcRef);
        $this->_em->persist($user);
        $this->_em->flush();
        return $user;
        


}
 public function addCalc($string){

        $calc = new \Catalog\Calculations();
        $calc->setEvaluation($string);
        $this->_em->persist($calc);
        $this->_em->flush();
        return $calc->getId();

        


    }

}
